home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / vortest / vordefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.1 KB  |  135 lines

  1. /*
  2.  * vordefs.h  copyright (c) 1991, 1992
  3.  * seth j. teller, seth@cs.berkeley.edu.
  4.  * all rights reserved
  5.  *
  6.  *  libvor.a is a voronoi partition/delaunay triangulation library based on 
  7.  *  steve fortune's plane sweep algorithm from "Algorithmica," 1987, "A 
  8.  *  Sweepline Algorithm for `Voronoi' Diagrams", volume 2, pp. 153-174.
  9.  *  
  10.  *  vordefs.h is the .h file used for compiling with this library.
  11.  */
  12.  
  13. #define MAXSITES 4096
  14.  
  15. /* GL DRAWING STUFF */
  16.  
  17. /* vertex: x, y */
  18. struct vertstruct {
  19.     float x, y;
  20.     int vpid;
  21.     };
  22.  
  23. /* vertex id w/neighbors */
  24. struct nvertstruct {
  25.     int nbr1, nbr2, onhull;
  26.     int vpid;
  27.     };
  28.  
  29. /* vertex: x, y, theta */
  30. struct vertthetastruct {
  31.     float x, y, theta;
  32.     int e1, e2;
  33.     };
  34.  
  35. /* edge: CLIPPED to reasonable bounds */
  36. struct edgestruct {
  37.     float x1, y1, x2, y2;
  38.     int nbr1, nbr2;
  39.     float xm, ym;           /* halfway between inducing voronoi sites */
  40.     };
  41.  
  42. typedef struct vertstruct VERT;
  43. typedef struct nvertstruct NVERT;
  44. typedef struct vertthetastruct VERTTHETA;
  45. typedef struct edgestruct EDGE;
  46.  
  47. /* triangle: holds POINTERS to three verts */
  48. struct tristruct {
  49.     VERT *v1, *v2, *v3;
  50.     };
  51.  
  52. struct circstruct {
  53.     float cx, cy, r;
  54.     int nbr1, nbr2, nbr3;
  55.     };
  56.  
  57. typedef struct tristruct TRI;
  58. typedef struct circstruct CIRC;
  59.  
  60. #define MAXVERTS (3 * MAXSITES)
  61. #define MAXEDGES (2 * MAXSITES)
  62. #define MAXTRIS  (MAXEDGES)
  63.  
  64. extern VERT GLsites[MAXVERTS];
  65. extern VERT verts[MAXVERTS];
  66. extern EDGE vedges[MAXEDGES];
  67. extern NVERT chverts[MAXVERTS];
  68. extern TRI  tris[MAXTRIS];
  69. extern CIRC circles[MAXTRIS];
  70.  
  71. /* load_vsites(): 
  72.     accept the n voronoi sites (x_n, y_n)
  73.     calculate and store the voronoi diagram over the n sites,
  74.     clipping all infinite edges to bbox: [xmin, ymin, xmax, ymax].
  75.     
  76.     note: if (xmin,ymin,xmax,ymax are all == 0.0), OR
  77.         if these do not enclose the data, a bounding box
  78.          will be computed over the input.
  79.  
  80.     returns:
  81.         -1 if error
  82.          0 otherwise
  83. */
  84. int
  85. load_vsites (
  86.     int n,
  87.     float usites[][2],  /* sites in x,y order */
  88.     float uxmin, float uymin, float uxmax, float uymax);
  89.  
  90. /*
  91.     find_vregion(sid, plen, pverts)
  92.         given a site id 'sid' from 0..nsites-1 inclusive, 
  93.         returns the voronoi polygon associated with that site
  94.         in the array 'pverts', and its length on call stack.
  95.  
  96.         the vertices are returned in counterclockwise order.
  97.  
  98.     returns:
  99.         -1 if error condition
  100.         plen > 2 [i.e., the # of verts in the voronoi polygon] otherwise
  101. */
  102. int
  103. find_vregion (
  104.     int vsid,
  105.     float pverts[][2]);
  106.  
  107. /*
  108.     int
  109.     find_dtriangles (**dtris)
  110.  
  111.     returns:
  112.         -1 if error condition, *dtris == NULL
  113.         o/wise, # of delaunay triangles, *dtris == array of TRIS (see voronoi.h)
  114. */
  115. int
  116. find_dtriangles (
  117.     TRI **dtris);
  118.  
  119. /*
  120.     int
  121.     find_convexhull (**chverts)
  122.  
  123.     returns:
  124.         if error condition
  125.              *chverts == NULL
  126.             returns -1 
  127.         o/wise, 
  128.             *chverts == array of named VERTs (see voronoi.h), in order around convex hull
  129.             *chvert[k].vpid == index of point in point set given to load_vertices()
  130.             returns # of convex hull vertices
  131. */
  132. int
  133. find_convexhull(
  134.     NVERT **chvertices);
  135.